﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MusicPlayerPlus.Interface.Base.Action.Input;
using MusicPlayerPlus.Core.Reflection.ActionParam.Action.Input;
using System.Reflection;
using MusicPlayerPlus.Interface.Model.Muisc;

namespace MusicPlayerPlus.Core.Reflection.Action.Input
{
    #region Base

    /// <summary>
    /// 自动执行动作接口
    /// </summary>
    public class RAutoExecuteAction : RAPBase<IAutoExecuteAction, APAutoExecuteAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("AutoExecute");

            AcitonParam.AutoExecute(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 添加按钮动作接口
    /// </summary>
    public class RAddToButtonAction : RAPBase<IAddToButtonAction, APAddToButtonAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("AddToButton");

            AcitonParam.AddToButton((title, action) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { title, action });
            });
        }
    }
    /// <summary>
    /// 添加菜单动作接口
    /// </summary>
    public class RAddToMenuAction : RAPBase<IAddToMenuAction, APAddToMenuAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("AddToMenu");

            AcitonParam.AddToMenu((title, action) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { title, action });
            });
        }
    }



    /// <summary>
    /// 设置主窗体
    /// </summary>
    public class RSetMainWindow : RAPBase<ISetMainWindow, APSetMainWindow>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("SetMainWindow");

            AcitonParam.SetMainWindow((win) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { win });
            });
        }
    }
    /// <summary>
    /// 主窗体 显示
    /// </summary>
    public class RMainWindowShow : RAPBase<IMainWindowShow, APMainWindowShow>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("MainWindowShow");

            AcitonParam.MainWindowShow(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 主窗体 隐藏
    /// </summary>
    public class RMainWindowHide : RAPBase<IMainWindowHide, APMainWindowHide>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("MainWindowHide");

            AcitonParam.MainWindowHide(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }


    /// <summary>
    /// 主窗体 最小化
    /// </summary>
    public class RMainWindowMin : RAPBase<IMainWindowMin, APMainWindowMin>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("MainWindowMin");

            AcitonParam.MainWindowMin(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 主窗体 最大化
    /// </summary>
    public class RMainWindowMax : RAPBase<IMainWindowMax, APMainWindowMax>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("MainWindowMax");

            AcitonParam.MainWindowMax(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }

    #endregion

    #region Media

    /// <summary>
    /// (改变后事件)进度条改变
    /// </summary>
    public class RTimeLineChangeAction : RAPBase<ITimeLineChangeAction, APTimeLineChangeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("TimeLineChange");

            AcitonParam.TimeLineChange((max, val) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { max, val });
            });
        }
    }
    /// <summary>
    /// (主动)进度条改变
    /// </summary>
    public class RChangeTimeLineAction : RAPBase<IChangeTimeLineAction, APChangeTimeLineAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("ChangeTimeLine");

            AcitonParam.ChangeTimeLine((val) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { val });
            });
        }
    }
    /// <summary>
    /// (改变后事件)音量改变
    /// </summary>
    public class RVolumeChangeAction : RAPBase<IVolumeChangeAction, APVolumeChangeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("VolumeChange");

            AcitonParam.VolumeChange((val) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { val });
            });
        }
    }
    /// <summary>
    /// (主动)音量改变
    /// </summary>
    public class RChangeVolumeAction : RAPBase<IChangeVolumeAction, APChangeVolumeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("ChangeVolume");

            AcitonParam.ChangeVolume((val) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { val });
            });
        }
    }

    /// <summary>
    /// 缓冲进度条改变
    /// </summary>
    public class RBufferingTimeLineChangeAction : RAPBase<IBufferingTimeLineChangeAction, APBufferingTimeLineChangeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("BufferingTimeLineChange");

            AcitonParam.BufferingTimeLineChange((max, val) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { max, val });
            });
        }
    }
    /// <summary>
    /// 播放状态改变
    /// </summary>
    public class RPlayStateChangeAction : RAPBase<IPlayStateChangeAction, APPlayStateChangeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("PlayStateChange");

            AcitonParam.PlayStateChange((val) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { val });
            });
        }
    }
    /// <summary>
    /// 播放顺序改变
    /// </summary>
    public class RPlayOrderChangeAction : RAPBase<IPlayOrderChangeAction, APPlayOrderChangeAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("PlayPlayOrderChange");

            AcitonParam.PlayPlayOrderChange((val) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { val });
            });
        }
    }
    /// <summary>
    /// 播放
    /// </summary>
    public class RPlayAction : RAPBase<IPlayAction, APPlayAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("Play");

            AcitonParam.Play(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 暂停
    /// </summary>
    public class RPauseAction : RAPBase<IPauseAction, APPauseAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("Pause");

            AcitonParam.Pause(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 停止
    /// </summary>
    public class RStopAction : RAPBase<IStopAction, APStopAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("Stop");

            AcitonParam.Stop(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 上一首
    /// </summary>
    public class RPreviousTrackAction : RAPBase<IPreviousTrackAction, APPreviousTrackAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("PreviousTrack");

            AcitonParam.PreviousTrack(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }
    /// <summary>
    /// 下一首
    /// </summary>
    public class RNextTrackAction : RAPBase<INextTrackAction, APNextTrackAction>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("NextTrack");

            AcitonParam.NextTrack(() =>
            {
                MethodInvoke(obj, methodExecute, new object[0] { });
            });
        }
    }

    #endregion

    #region IChangeEvent

    /// <summary>
    /// Dictionary数据改变时
    /// </summary>
    public class RDictionaryChange : RAPBase<IDictionaryChange, APDictionaryChange>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("DictionaryChange");

            AcitonParam.DictionaryChange((guid, data) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { guid, data });
            });
        }
    }
    /// <summary>
    /// 播放列表改变时
    /// </summary>
    public class RPlayListChange : RAPBase<IPlayListChange, APPlayListChange>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("PlayListChange");

            AcitonParam.PlayListChange((guid, list) =>
            {
                MethodInvoke(obj, methodExecute, new object[2] { guid, list });
            });
        }
    }
    /// <summary>
    /// 播放中的列表改变时
    /// </summary>
    public class RMuiscListChange : RAPBase<IMuiscListChange, APMuiscListChange>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("MuiscListChange");

            AcitonParam.MuiscListChange((data) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { data });
            });
        }
    }
    /// <summary>
    /// 播放的歌曲改变时
    /// </summary>
    public class RPlayMusicChange : RAPBase<IPlayMusicChange, APPlayMusicChange>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            MethodInfo methodExecute = classType.GetMethod("PlayMusicChange");

            AcitonParam.PlayMusicChange((list) =>
            {
                MethodInvoke(obj, methodExecute, new object[1] { list });
            });
        }
    }



    /// <summary>
    /// 播放的歌曲改变时
    /// </summary>
    public class ROrientationActionChange : RAPBase<IOrientationActionChange, APOrientationActionChange>
    {
        protected override void Instantiation(Type classType, object obj)
        {
            try
            {
                PropertyInfo propertyInfo = classType.GetProperty("OrientationAction_Key");
                MethodInfo methodExecute = classType.GetMethod("OrientationActionChange");

                object keyobj = propertyInfo.GetValue(obj, null);
                string mainkey = keyobj as string;
                if (string.IsNullOrEmpty(mainkey))
                {
                    return;
                }

                AcitonParam.OrientationActionChange(mainkey, (keydata, objdata) =>
                {
                    MethodInvoke(obj, methodExecute, new object[2] { keydata, objdata });
                });
            }
            catch (Exception ex)
            {

            }
        }
    }

    #endregion
}
